//package com.touchfired.common.event.handler.impl;
//
//import com.touchfired.common.constants.ClientInfo;
//import com.touchfired.common.constants.EventCode;
//import com.touchfired.common.constants.GlobalConstants;
//import com.touchfired.common.context.ServerContext;
//import com.touchfired.common.message.BaseMessage;
//import com.touchfired.common.message.transfer.MessageConsoler;
//import io.netty.channel.Channel;
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.handler.codec.http.HttpHeaders;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.net.URLDecoder;
//
///**
// * 连接成功事件码处理器
// *
// * @author 幸佳俊
// */
//@Component
//public class EventCodeConnectedHandler extends BaseEventCodeHandler {
//
//    @Autowired
//    private ServerContext serverContext;
//
//    public EventCodeConnectedHandler() {
//        super(EventCode.CLIENT_CONNECTED);
//    }
//
//    @Override
//    public EventCodeHandler doHandle(ChannelHandlerContext ctx, ClientInfo clientInfo, BaseMessage message) throws Exception {
//        Channel channel = ctx.channel();
//        HttpHeaders headers = (HttpHeaders) message.getOtherMap().get(GlobalConstants.HEADERS);
//        if (headers.contains(GlobalConstants.USERNAME)) {
//            String username = URLDecoder.decode(headers.get(GlobalConstants.USERNAME), "UTF-8");
//            clientInfo.setName(username);
//        }
//        clientInfo.appendEventNode(EventCode.valueOf(message.getToCode()));
//        MessageConsoler.info(channel.remoteAddress().toString() + "连接成功");
//        serverContext.updateClientInfo(clientInfo);
//        return null;
//    }
//}
